package com.hzjh.base.ext.utils

import android.content.Intent
import android.net.Uri
import com.hzjh.base.ext.R
import com.hzjh.base.style.weight.ToastKt.toastCenter
import com.hzjh.base.utils.other.CommUtils

object AppUpdateUtils {
    /**
     * 启动Google Play APP详情页
     */
    fun startGooglePlay(packageName: String) {
        try {
            val intent = Intent(Intent.ACTION_VIEW).apply {
                data = Uri.parse(
                    "https://play.google.com/store/apps/details?id=$packageName"
                )
                setPackage("com.android.vending")
                flags = Intent.FLAG_ACTIVITY_NEW_TASK
            }
            CommUtils.getContext().startActivity(intent)
        }catch (e:Exception){
            CommUtils.getContext().toastCenter(CommUtils.getString(R.string.jh_no_google_play))
        }
    }
}